//
//  LLMainViewController.swift
//  新浪微博
//
//  Created by mac on 16/5/19.
//  Copyright © 2016年 mac.com. All rights reserved.
//

import UIKit

class LLMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let mainTabBar = LLTabbar()
        mainTabBar.plusBtn.addTarget(self, action: Selector("plusBtnDidClick"), forControlEvents: .TouchUpInside)
//        mainTabBar.backgroundImage  = UIImage(named: "tabbar_background")
        setValue(mainTabBar, forKey: "tabBar")
        addChildViewControllers()
    }
   @objc private func plusBtnDidClick(){
    
    print("我点了")
    
    }
    private func addChildViewController(vc: UIViewController,title:String ,imagename:String) {
        let tabbaritem = LLTabbarItem()
        vc.tabBarItem = tabbaritem
        vc.title  = title
        vc.tabBarItem.image = UIImage(named: imagename)
        //设置选中时的图片  需要设置渲染模式 2. 通过在xcasserts中设置
        vc.tabBarItem.selectedImage = UIImage(named: imagename + "_selected")?.imageWithRenderingMode(.AlwaysOriginal)
        //设置title的颜色
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: .Selected)
        //统一设置title的颜色
//        tabBar.tintColor = UIColor.orangeColor()
        //内嵌到导航控制器中
        let nav = LLNavViewController(rootViewController: vc)
        addChildViewController(nav)
        
    }
    private func addChildViewControllers() {
        addChildViewController(LLHomeViewController(), title: "首页", imagename: "tabbar_home")
        addChildViewController(LLDiscoverViewController(), title: "发现", imagename: "tabbar_discover")
        addChildViewController(LLMessageViewController(), title: "消息", imagename: "tabbar_message_center")
addChildViewController(LLProfileViewController(), title: "我的", imagename: "tabbar_profile")
        
        
    }

}
